package com.dongdongshop.controller;

import com.dongdongshop.admin.vo.ContentCategoryVO;
import com.dongdongshop.common.Result;
import com.dongdongshop.service.CateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("cate")
public class CategoryController {
    @Autowired
    private CateService cateService;

    @PostMapping("getAll")
    public Result getAll(){
        List<ContentCategoryVO> list = cateService.getAll();
        return Result.OK().setData(list);
    }

    @PostMapping("add")
    public Result add(@RequestBody ContentCategoryVO contentCategoryVO){
        cateService.add(contentCategoryVO);
        return Result.OK();
    }

    @PostMapping("getById")
    public Result getById(@RequestParam Long id){
        List<ContentCategoryVO> list=cateService.getById(id);
        return Result.OK().setData(list);
    }

    @PostMapping("update")
    public Result update(@RequestBody ContentCategoryVO contentCategoryVO) {
        cateService.update(contentCategoryVO);
        return Result.OK();
    }
}
